const { defineConfig } = require("@vue/cli-service");
const Mock = require("mockjs");
module.exports = defineConfig({
  transpileDependencies: true,
  devServer: {
    proxy: {
      "/api": {
        target: "http://localhost:3000",
        pathRewrite: { "^/api": "" },
      },
    },
    setupMiddlewares(middlewares, devServer) {
      devServer.app.get("/list", (req, res) => {
        const { list } = Mock.mock({
          "list|10": [
            {
              id: "@id",
              "images|4-10": ["@image(180x150, @color)"],
              title: "@ctitle",
              word: "@cword(10, 20)",
              "price|10-10000": 1,
              "sell|10-10000000": 1,
              "maxCount|5-20": 1,
            },
          ],
        });
        // res.headers['x-total-count'] = 100
        res.send({
          total: 100,
          data: list
        })
      });

      return middlewares;
    },
  },
});
